﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
namespace DAL
{
   public class UserTypeDAL
    {
        DBHelper db = new DBHelper();
        public bool LoginUser(UserType type)
        {
            string sql = $"select AccountName, AccountPwd from [dbo].[AcoutBk] where AccountName='{type.AccountName}' and AccountPwd='{type.AccountPwd}'";
            if (db.GetData(sql).Tables[0].Rows.Count > 0)
            {
                return true;
            }
            return false;
        }
        public bool Add(UserType type)
        {
            string sql = $"insert into [dbo].[AcoutBk](AccountName, AccountPwd,AccountAge,AccountPhone,AccountAddres,Mailbox) values ('{type.AccountName}','{type.AccountPwd}','{type.AccountAge}','{type.AccountPhone}','{type.AccountAddres}','{type.Mailbox}')";
            bool result = true;
            if (db.SetData(sql))
            {
                result = false;
            }
            return result;
        }
        public bool Add1(UserType type)
        {
            string sql = $"insert into [dbo].[Manage](ManageName, ManagePwd,MangeAddress) values ('{type.ManageName}','{type.ManagePwd}','{type.MangeAddress}')";
            bool result = true;
            if (db.SetData(sql))
            {
                result = false;
            }
            return result;
        }
    }
}
